home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / swirly-pattern.scm < prev    next >
Encoding:
Text File  |  2005-06-30  |  2.8 KB  |  92 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; Pattern00 --- create a swirly tileable pattern
  5. ; Copyright (C) 1997 Federico Mena Quintero
  6. ; federico@nuclecu.unam.mx
  7. ;
  8. ; This program is free software; you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License as published by
  10. ; the Free Software Foundation; either version 2 of the License, or
  11. ; (at your option) any later version.
  12. ;
  13. ; This program is distributed in the hope that it will be useful,
  14. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ; GNU General Public License for more details.
  17. ;
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program; if not, write to the Free Software
  20. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22.  
  23. (define (script-fu-swirly-pattern qsize angle times)
  24.   (define (whirl-it img drawable angle times)
  25.     (if (> times 0)
  26.     (begin
  27.       (plug-in-whirl-pinch 1 img drawable angle 0.0 1.0)
  28.       (whirl-it img drawable angle (- times 1)))))
  29.  
  30.   (let* ((hsize (* qsize 2))
  31.      (img-size (* qsize 4))
  32.      (img (car (gimp-image-new img-size img-size RGB)))
  33.      (drawable (car (gimp-layer-new img img-size img-size
  34.                     RGB-IMAGE "Swirly pattern"
  35.                     100 NORMAL-MODE))))
  36.  
  37.     (gimp-context-push)
  38.  
  39.     (gimp-image-undo-disable img)
  40.     (gimp-image-add-layer img drawable 0)
  41.  
  42.     ; Render checkerboard
  43.  
  44.     (gimp-context-set-foreground '(0 0 0))
  45.     (gimp-context-set-background '(255 255 255))
  46.  
  47.     (plug-in-checkerboard 1 img drawable 0 qsize)
  48.  
  49.     ; Whirl upper left
  50.  
  51.     (gimp-rect-select img 0 0 hsize hsize CHANNEL-OP-REPLACE 0 0)
  52.     (whirl-it img drawable angle times)
  53.     (gimp-invert drawable)
  54.  
  55.     ; Whirl upper right
  56.  
  57.     (gimp-rect-select img hsize 0 hsize hsize CHANNEL-OP-REPLACE 0 0)
  58.     (whirl-it img drawable (- angle) times)
  59.  
  60.     ; Whirl lower left
  61.  
  62.     (gimp-rect-select img 0 hsize hsize hsize CHANNEL-OP-REPLACE 0 0)
  63.     (whirl-it img drawable (- angle) times)
  64.  
  65.     ; Whirl lower right
  66.  
  67.     (gimp-rect-select img hsize hsize hsize hsize CHANNEL-OP-REPLACE 0 0)
  68.     (whirl-it img drawable angle times)
  69.     (gimp-invert drawable)
  70.  
  71.     ; Terminate
  72.  
  73.     (gimp-selection-none img)
  74.     (gimp-image-undo-enable img)
  75.     (gimp-display-new img)
  76.  
  77.     (gimp-context-pop)))
  78.  
  79. (script-fu-register "script-fu-swirly-pattern"
  80.             _"_Swirly..."
  81.             "Create a swirly pattern"
  82.             "Federico Mena Quintero"
  83.             "Federico Mena Quintero"
  84.             "June 1997"
  85.             ""
  86.             SF-ADJUSTMENT _"Quarter size"             '(20 0 2048 1 10 0 1)
  87.             SF-ADJUSTMENT _"Whirl angle"              '(90 0 360 1 1 0 0)
  88.             SF-ADJUSTMENT _"Number of times to whirl" '(4 0 128 1 1 0 1))
  89.  
  90. (script-fu-menu-register "script-fu-swirly-pattern"
  91.              _"<Toolbox>/Xtns/Script-Fu/Patterns")
  92.